package spring.proxyfactorybean;


import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;

/**
 * @author wangjinjing
 * @version 1.0
 * @date 2021/11/23 17:26
 */
public class MyAspect implements MethodInterceptor {

    @Override
    public Object invoke(MethodInvocation arg) throws Throwable {
        // 前增强
        check();
        except();
        Object obj = arg.proceed();
        // 后增强
        log();
        moniter();
        return obj;
    }

    public void check() {
        System.out.println("模拟权限控制。");
    }

    public void except() {
        System.out.println("模拟异常处理。");
    }

    public void log() {
        System.out.println("模拟日志记录。");
    }

    public void moniter() {
        System.out.println("模拟性能监测。");
    }
}
